package com.lienlq.voicemusic.entity;

import android.os.Parcel;
import android.os.Parcelable;

public class Track implements Parcelable{
	
	private String name;
	private String album;
	private String artist;
	private String musician;
	private int numberListen;
	private String uri;  
	private String img;
	
	private Track(Parcel p) { 
		this.name = p.readString();
		this.artist = p.readString();
		this.album = p.readString();
		this.uri = p.readString();
		this.numberListen = p.readInt();
	}

	public static final Parcelable.Creator CREATOR =new Parcelable.Creator(){

		@Override
		public Track createFromParcel(Parcel in) { 
			return new Track(in);
		}

		@Override
		public Track[] newArray(int size) {
			// TODO Auto-generated method stub
			return new Track[size];
		}
		
	};


	
	public Track(String track, String album, String artist, String musician, 
			String uri, String img,
			int numberListen) {  
		this.album = album;
		this.artist = artist;
		this.musician = musician;
		this.numberListen = numberListen;
		if (track.equals("")) {
			throw new IllegalArgumentException("Uri in contructor must be not null");
		} else {
			this.name = track;
		}
		if (uri.equals("")) {
			throw new IllegalArgumentException("Uri in contructor must be not null");
		} else {
			this.uri = uri;
		}
		this.img = img;
	}
	
	public String getImg() {
		return img;
	}
	public String getUri() {
		return uri;
	}
	
	public String getNumberListen() {
		return Integer.toString(numberListen); 
	}
	public void setNumberListen(int numberListen) {
		if (numberListen < 0 ) throw new IllegalArgumentException("setListeningNumber() method, argument must be positive");
		this.numberListen = numberListen;
	}
	
	public String getTrack() {
		return name;
	}
	public void setTrack(String track) {
		this.name = track;
	}
	public String getAlbum() {
		return album;
	}
	public void setAlbum(String album) {
		this.album = album;
	}
	public String getArtist() {
		return artist;
	}
	public void setArtist(String artist) {
		this.artist = artist;
	}
	public String getMusician() {
		return musician;
	}
	public void setMusician(String musician) {
		
		this.musician = musician;
	}
	@Override
	public int describeContents()  {
		return 0;
	}
	@Override
	public void writeToParcel(Parcel dest, int flags) { 
		dest.writeString(name);
		dest.writeString(this.artist);
		dest.writeString(this.album);
		dest.writeString(this.uri);
		dest.writeInt(this.numberListen);
	}
}
